package app_config

import (
	"fmt"
	"github.com/spf13/viper"
)

type AppConfig struct {
	MySQLConfig
	RedisConfig
}

type MySQLConfig struct {
	Host     string
	Port     int
	User     string
	Password string
	Database string
}

type RedisConfig struct {
	Host     string
	Port     int
	Password string
}

var AppConf AppConfig

func InitApp() {
	// 读取yaml
	viper.SetConfigFile("../app_config/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		fmt.Println("配置文件读取失败111：", err)
		return
	}

	viper.Unmarshal(&AppConf)
	fmt.Println(AppConf)
}
